/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 *//*

package cz.worsik.android.test.rideshare.util;

import android.text.InputType;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import cz.worsik.android.test.rideshare.R;
import cz.worsik.android.test.rideshare.MainActivity;
import cz.worsik.android.test.rideshare.constants.ViewConst;
import cz.worsik.android.test.rideshare.model.list.ETableType;
import cz.worsik.android.test.rideshare.util.listener.AllPickOnClickListener;
import cz.worsik.android.test.rideshare.util.listener.NoAllPickOnClickListener;
import cz.worsik.android.test.rideshare.util.listener.PopupCancelListener;
import cz.worsik.android.test.rideshare.util.listener.RadioCheckChangedListener;
import cz.worsik.android.test.rideshare.util.listener.RidiOnCheckListener;
import cz.worsik.android.test.rideshare.util.listener.SaveOnClickListener;
import cz.worsik.android.test.rideshare.util.listener.SavePaymentListener;
import cz.worsik.android.test.rideshare.util.listener.UlozCestujicihoListener;

*/
/**
 *
 * @author 231260
 *//*

public class ViewGenerator {
	
	LayoutInflater inflater;

	public ViewGenerator(LayoutInflater inflater) {
		this.inflater = inflater;
	}
	
	public static void generateBilanceHistory(MainActivity a, ETableType type)
	{
		
	}
	
	public void generateNovaJizdaPopupWindow(MainActivity a)
	{
        //Inflate the view from a predefined XML layout
        View layout = inflater.inflate(R.layout.jizda_popup_layout,
                (ViewGroup) a.findViewById(R.id.jizda_popup_layout));
        // create a 300px width and 470px height PopupWindow
        a.popup_window = new PopupWindow(layout, 320, 480, true);
        // display the popup in the center
        a.popup_window.showAtLocation(layout, Gravity.BOTTOM, 0, 0);

		// nastavit combobox
		Spinner spinner = (Spinner) layout.findViewById(R.id.driver_select);
		a.setDriversToSpinner(spinner);
		
		// generovat checkboxy
		a.getDb().open();
		String[] passengers = a.getDb().getAllContacts();
		a.getDb().close();
		
		TableLayout table = (TableLayout) layout.findViewById(R.id.check_table);
		table.removeAllViews();
		ViewConst.CHECKBOX_COUNT = 0;
		
		TableRow box_row = null;
		for (int i=0; i<=passengers.length; i++)
		{
			if (ViewConst.DEBUG) {
				Log.i("GENERATING CHECKBOXES", "Generuji checkbox cislo "+(i+1));
			}
			
			if (i % 2 == 0)
			{
				box_row = new TableRow(a);
				box_row.setId(ViewConst.ROW_START_ID+i);
				
				if (ViewConst.DEBUG) {
					Log.i("SELECT TABLE ROW", "Vybral jsem radek s ID: "+box_row.getId());
				}
//				label_row = new TableRow(this);
			}
			
			if (i == 0)
			{
				CheckBox all = new CheckBox(a);
					all.setId(ViewConst.CHECKBOX_START_ID);
					all.setWidth(ViewConst.CHECKBOX_WIDTH);
					all.setHeight(ViewConst.CHECKBOX_HEIGHT);
					all.setGravity(android.view.Gravity.CENTER);
					all.setText(a.getString(R.string.check_all));
					all.setOnCheckedChangeListener(new AllPickOnClickListener(layout));
					
				if (ViewConst.DEBUG) {
					Log.i("CHECKBOX GENERATED", "All checkbox byl vygenerovan s ID: "+all.getId());
				}
				
				box_row.addView(all);
			}
			else
			{
				CheckBox cb = new CheckBox(a);
					cb.setId(ViewConst.CHECKBOX_START_ID+i);
					cb.setWidth(ViewConst.CHECKBOX_WIDTH);
					cb.setHeight(ViewConst.CHECKBOX_HEIGHT);
					cb.setGravity(android.view.Gravity.CENTER);
					cb.setText(passengers[i-1]);
					cb.setOnCheckedChangeListener(new NoAllPickOnClickListener(layout));

				if (ViewConst.DEBUG) {
					Log.i("CHECKBOX GENERATED", ""+i+". checkbox byl vygenerovan s ID: "+cb.getId());
				}

				box_row.addView(cb);
			}

			if (ViewConst.DEBUG) {
				Log.i("UPDATE ROW", ""+i+". checkbox byl pridan do radku s ID: "+box_row.getId());
			}
			
			if (i % 2 == 1)
			{
				if (ViewConst.DEBUG) {
					Log.i("UPDATE TABLE", "Pridavam radek s ID: "+box_row.getId()+" do tabulky");
				}
				
				table.addView(box_row);
			}
			else if (i == passengers.length)
			{
				if (ViewConst.DEBUG) {
					Log.i("UPDATE TABLE", "Pridavam radek s ID: "+box_row.getId()+" do tabulky");
				}
				
				table.addView(box_row);
			}
			
			ViewConst.CHECKBOX_COUNT ++;
			if (ViewConst.DEBUG) {
				Log.i("CHECKBOX COUNT","(aktuální počet = "+ViewConst.CHECKBOX_COUNT+")");
			}
		}
		
		// nastaveni radio buttonu
		RadioButton tam_btn = (RadioButton) layout.findViewById(R.id.tam);
		tam_btn.setChecked(true);
		RadioGroup smer = (RadioGroup) layout.findViewById(R.id.smer);
		smer.setOnCheckedChangeListener((RadioGroup.OnCheckedChangeListener) new RadioCheckChangedListener(a));
		TextView tam_label = (TextView) layout.findViewById(R.id.tam_label);
		TextView zpet_label = (TextView) layout.findViewById(R.id.zpet_label);
		tam_label.setClickable(true);
		zpet_label.setClickable(true);
		tam_label.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				RadioButton tam_btn = (RadioButton) v.findViewById(R.id.tam);
				tam_btn.setChecked(true);
			}
		});
		zpet_label.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				RadioButton zpet_btn = (RadioButton) v.findViewById(R.id.zpet);
				zpet_btn.setChecked(true);
			}
		});

		Button save_btn = (Button) layout.findViewById(R.id.save_day);
		save_btn.setOnClickListener(new SaveOnClickListener(a, layout));
		
		EditText input = (EditText) layout.findViewById(R.id.popup_datum);
		
		input.setText(KalendarTools.getTextForDateLabel(a.getApplicationContext(), a.getZobrazeno().getTime()));
		input.setFocusable(false);
		
		//setDefaultValues();
	}
	
	public View generateNovyCestujiciPopupWindow(RideShareActivity a)
	{
        //Inflate the view from a predefined XML layout
        View layout = inflater.inflate(R.layout.cestujici_popup_layout,
                (ViewGroup) a.findViewById(R.id.cestujici_popup_layout));
        // create a 300px width and 470px height PopupWindow
        a.popup_window = new PopupWindow(layout, 320, 480, true);
        // display the popup in the center
        a.popup_window.showAtLocation(layout, Gravity.BOTTOM, 0, 0);

		EditText input;
		CheckBox checkbox;
		
		input = (EditText) layout.findViewById(R.id.popup_jmeno);
		input.setText("");
		
		input = (EditText) layout.findViewById(R.id.popup_cena);
		input.setInputType(InputType.TYPE_CLASS_NUMBER);
		input.setText("25");
		input.setEnabled(false);

		checkbox = (CheckBox) layout.findViewById(R.id.popup_ridi_check);
		checkbox.setChecked(false);
		checkbox.setOnCheckedChangeListener(new RidiOnCheckListener(input));
		
		Button save = (Button) layout.findViewById(R.id.popup_uloz);
		save.setOnClickListener(new UlozCestujicihoListener(a));
		Button cancel = (Button) layout.findViewById(R.id.popup_zrus);
		cancel.setOnClickListener(new PopupCancelListener(a));
		
		return layout;
	}
	
	public void generateNovaPlatbaPopupWindow(RideShareActivity a)
	{
        //Inflate the view from a predefined XML layout
        View layout = inflater.inflate(R.layout.platba_popup_layout,
                (ViewGroup) a.findViewById(R.id.platba_popup_layout));
        // create a 300px width and 470px height PopupWindow
        a.popup_window = new PopupWindow(layout, 320, 480, true);
        // display the popup in the center
        a.popup_window.showAtLocation(layout, Gravity.BOTTOM, 0, 0);

		EditText input;
		Spinner select;
		
		input = (EditText) layout.findViewById(R.id.popup_datum);
		input.setText(a.getDen()+"."+a.getCisloMesice()+". "+a.getRok());
		input.setFocusable(false);

		select = (Spinner) layout.findViewById(R.id.popup_contact_paying);
		a.setContactsToSpinner(select);

		select = (Spinner) layout.findViewById(R.id.popup_contact_receiving);
		a.setContactsToSpinner(select);
		
		input = (EditText) layout.findViewById(R.id.popup_amount);
		input.setInputType(InputType.TYPE_CLASS_NUMBER);
		
		Button save = (Button) layout.findViewById(R.id.popup_save);
		save.setOnClickListener(new SavePaymentListener(a));
		Button cancel = (Button) layout.findViewById(R.id.popup_cancel);
		cancel.setOnClickListener(new PopupCancelListener(a));
	}
}
*/
